package d0316;

public class homework {
    //定义一个div方法 捕获一个NumberFormatException异常 抛出ArithmeticException异常
    public float div(String x,String y) throws ArithmeticException {
        int x1 = 0;
        int y1 = 0;
        try {
            x1 = Integer.parseInt(x);
            y1 = Integer.parseInt(y);
        } catch (NumberFormatException e) {
            e.printStackTrace();
        } finally {
            return x1 / y1;
        }
    }

    public static void main(String[] args) {
        homework myException = new homework();
        try {
            myException.div("abc", "0");
        } catch (ArithmeticException e) {
            e.printStackTrace();
        }
    }}
